home *** CD-ROM | disk | FTP | other *** search
- video_demo:
-
- **Set up equates for box size
- box_top: equ 100
- box_left: equ 60
- box_bottom: equ 360 box hieght is 260
- box_right: equ 580 box width is 520
- **eautes for blob limits
- blob_max_left: equ box_left
- blob_max_right: equ box_right-32 **32 is width of icl8
- blob_max_top: equ box_top
- blob_max_bottom: equ box_bottom-32
-
- outer_border: equ 34 width of the outer border
- border: equ 15 width of the inner border
- purple: equ 31 colour purple
- red: equ 70
- black: equ 255 colour black
-
- blob_id: equ 128 the blob is icl8 ID 128
- ************global variables
- blob_pointer: globoff.l 1 pointer to blob grafic data
- blob_handle: globoff.l 1 handle to blob grafic data
- owch_handle: globoff.l 1 handle of owch sound
- eek_handle: globoff.l 1 handle off eek sound
- *********************************************************************************
- bsr a5_init *mandatory
- bsr init_mac *mandatory
- bsr init_graph_lib *initialise the graphics library
- bsr hide_mouse hide the mouse cursor
- move.l #1024,d0 *get 1k for icl8 to live in
- bsr getmem
- bsr lockmem *lock it
- move.l a0,blob_handle(a5) *so we can dispose it when we quit
- move.l (a0),a0 *get pointer to the memory
- move.l a0,blob_pointer(a5)
- **draw a red box
- move.w #red,d0
- move.w #box_left-outer_border,d1
- move.w #box_right+outer_border,d2
- move.w #box_top-outer_border,d3
- move.w #box_bottom+outer_border,d4
- bsr box_256
- **draw a purple box
- move.w #purple,d0 colour purple
- move.w #box_left-border,d1 start x
- move.w #box_right+border,d2 end x
- move.w #box_top-border,d3 start y
- move.w #box_bottom+border,d4 end y
- bsr box_256
- **now a black box inside it to make a window
- move.w #black,d0 colour=black
- move.w #box_left,d1 start x
- move.w #box_right,d2 end x
- move.w #box_top,d3 start y
- move.w #box_bottom,d4 end y
- bsr box_256
- **print the title
- lea hello_string(pc),a0 print box title
- move.w #7,d1 x
- move.w #7,d2 y
- move.w #52,d0 colour
- bsr print_string_8
-
- **get owch sound.
-
- move.w #128,d0
- bsr get_sound handle in a0
- move.l a0,d0
- move.l d0,owch_handle(a5)
-
- **get eek sound
- move.w #129,d0
- bsr get_sound
- move.l a0,d0
- move.l d0,eek_handle(a5)
- **now get the sprite
- MOVE.W #blob_id,D0 icl8 ID
- move.l blob_pointer(a5),A1 *get_icl8 needs to know where to put it.
-
- BSR GET_ICL8 load in the blob icl8 at my_data
- TST.W D0
- BMI.S QUIT couldn't find it!
-
- move.l blob_pointer(a5),A1 point to blob data
- **now set up vectors
- blob_x: requ d0
- blob_y: requ d1
- vector_x: requ d5
- vector_y: requ d6
-
-
- move.w #1,`vector_x x vector - speed=1 pix per frame
- move.w #1,`vector_y y vector - speed=1 pix per frame
-
- move.w #200,`blob_x initial starting position
- move.w #200,`blob_y
-
- bounce_loop:
- ; movem.l d0-d2/a1,-(sp) uncomment these lines to add a 1 tick delay
- ; move.l #1,d0 wait for two ticks.
- ; bsr wait
- ; movem.l (sp)+,d0-d2/a1
-
- bsr icl8_print draw the blob
-
- add.w `vector_x,`blob_x update position
- add.w `vector_y,`blob_y
-
- bsr.s check_boundries check and adjust vectors if necessary.
- movem.l d0-d1/a1,-(sp) *save x,y and pointer to blob
- bsr plot_a_star plot a random star
-
- bsr getkey_turbo **see manual for keymapping
- tst.w d0
- bmi.s quit *key pressed
-
- movem.l (sp)+,d0-d1/a1
- bra.s bounce_loop
- QUIT: movem.l (sp)+,d0-d1/a1
- bsr show_mouse mouse cursor back on
- move.l blob_handle(a5),a0
- bsr releasemem
- rts *end of prog.
-
- *********************Misc subroutines**********************
- check_boundries:
- **we check blob_x and y and if close to the box boundries we reverse the relevant
- **vector.
- cmpi.w #blob_max_left,`blob_x
- bgt.s not_min_x hasn't passed minimum x boundry
- neg.w `vector_x reverse the x vector
- bra.s done_x check y
- not_min_x: cmpi.w #blob_max_right,`blob_x
- blt.s done_x
- neg.w `vector_x
- done_x: cmpi.w #blob_max_top,`blob_y
- bgt.s not_min_y
- neg.w `vector_y
-
- movem.l d0-d4,-(sp) save coords and vectors
- bsr random
- andi.w #$f,d0 gt a random number less than 16
- cmpi.w #2,d0 if its greater than 2 then dont go owch
- bge.s dont_go_owch
- move.l owch_handle(a5),a0
- bsr run_sound make owch sound
- dont_go_owch:
- movem.l (sp)+,d0-d4 get coords and vectors back
- bra.s done_y
-
- not_min_y: cmpi.w #blob_max_bottom,`blob_y
- blt.s done_y
- neg.w `vector_y
- movem.l d0-d4,-(sp) save coords and vectors
- bsr random
- andi.w #$f,d0 gt a random number less than 16
- cmpi.w #2,d0 if its greater than 2 then dont go eek
- bge.s dont_go_eek
- move.l eek_handle(a5),a0
- bsr run_sound make owch sound
- dont_go_eek: movem.l (sp)+,d0-d4 restore coords and vectors
-
- done_y: rts
-
- ***********
-
- **plot_a_star calls random to get values for a star position and colour.
- plot_a_star: bsr random get long random number in d0
- andi.w #$f,d0 make less than 16
- cmpi.w #1,d0
- blt.s do_star if less than 4 then do a start (1 in 16 chance)
- rts
- do_star:
- bsr random
- andi.l #$1ff,d0 make in the range of 0-511
- add.w #box_left,d0
- move.w d0,d7 save x coord
- bsr random
- andi.l #$ff,d0
- add.w #box_top,d0
- move.w d0,d2 *y coord
- move.w d7,d1 *x coord
- bsr plot_256 *plot it
- rts
-
-
- hello_string: dc.b "The annoying Blob - An Example for Fantasm V4.00.",0
- even
- global video_demo
-
- extern init_mac,a5_init
- extern init_graph_lib,box_256,getkey_turbo,random
- extern icl8_print,GET_ICL8,plot_256,wait
- extern hide_mouse,show_mouse,print_char_8,print_string_8
- extern getmem,lockmem,releasemem,get_sound,run_sound
-